<script setup lang="ts">
const props: any = defineProps<{
    ujt: any;
    showtype?: number;
}>();
const { $fn, $db, $global } = props.ujt;
const { initUserChannel } = $fn.useUser(props);

initUserChannel();

function addItem() {
    $db.channeluser.cur.us = '';
    $db.channeluser.cur.pw = '';
    $db.channeluser.cur.lv = 0;
    $global.pop['popadduser'].stat = 1;
    $global.pop['popadduser'].tit = $global.lang.channeluser.ui.add;
}
</script>

<template>
    <PopBox :ujt="ujt" id="popadduser" :full="1">
        <UserRegManage :ujt="ujt" v-if="$global.pop['popadduser']?.stat">
            <template #btn>
                <div @pointerdown="$global.pop['popadduser'].stat = 0">
                    {{ $fn.lg('asai.close') }}
                </div>
            </template>
        </UserRegManage>
    </PopBox>

    <UserListManage
        v-if="$db.channeluser?.stat"
        :ujt="ujt"
        :showtype="showtype"
    >
        <template v-if="!showtype" #tit>
            <h1>{{ $fn.lg('channeluser.ui.list') }}</h1>
        </template>
        <template #btn>
            <div class="as-user-btns">
                <div class="cur" @pointerdown="addItem()">
                    {{ $fn.lg('channeluser.ui.add') }}
                </div>
                <div v-if="!showtype" @pointerdown="$fn.sethash('')">
                    {{ $fn.lg('asai.index') }}
                </div>
                <div v-if="!showtype" @pointerdown="$fn.sethash('user/exit/')">
                    {{ $fn.lg('channeluser.ui.exit') }}
                </div>
            </div>
        </template>
    </UserListManage>
</template>

<style scoped lang="scss"></style>
